<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  
<%
	String path = request.getContextPath();
	// 获得本项目的地址(例如: http://localhost:8080/MyApp/)赋值给basePath变量 
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	// 将 "项目路径basePath" 放入pageContext中，待以后用EL表达式读出。 
	pageContext.setAttribute("basePath", basePath);
	//out.write(basePath);
%>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>用户信息添加</title>

<meta name="description"
	content="Source code generated using layoutit.com">
<meta name="author" content="LayoutIt!">

<link href="<%=basePath %>bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="<%=basePath %>bootstrap/css/style.css" rel="stylesheet">

<style type="text/css">
/**文本框内容右对齐**/
label{
	text-align:right;
}
/**自定义row的行距**/
.rowHeigth {
	margin-top: 10px;
}
</style>
<!-- 验证function -->
<script type="text/javascript">	
<!-- 验证姓名-->
		function checkName(){
			//获取用户名输入控件对象的内容
				var txtName = document.getElementById("txtUserName").value;
				//信息提示框
				var sptxtName = document.getElementById("sptxtName");
				if(txtName == null || txtName == ""){
					//验证失败
					isChecked = false;
					//提示信息					
					sptxtName.innerHTML = "请输入姓名！";
					sptxtName.style.color = "red";
					//msg += "请输入姓名！\n"
					document.getElementById("txtUserName").focus();
					//修改标志变量
					return false;
				}else{
					sptxtName.innerHTML="";
					//修改标志变量
					return true;
				}
		}
		
		<!--验证登录密码-->	
		function checkPsw(){
			//密码非空验证
				var txtPsw = document.getElementById("txtUserPsw").value;
				
				//信息提示框
				var sptxtPsw = document.getElementById("sptxtPsw");
				if(txtPsw == null || txtPsw == ""){		
					
					//错误提示信息
					//提示信息					
					sptxtPsw.innerHTML = "请输入密码！";
					sptxtPsw.style.color = "red";
					document.getElementById("txtUserPsw").focus();
					return false;
				}else{
					//验证通过  清空提示内容
					sptxtPsw.innerHTML = "";
					return true;
				}
		}
		<!--验证性别-->	
		function checkSex(){
			//获取用户名输入控件对象的内容
			var txtSex = document.getElementById("selectSext").value;
			//信息提示框
			var sptxtSex = document.getElementById("sptxtSex");
			if(txtSex == null || txtSex == ""){
				//验证失败
				isChecked = false;
				//提示信息					
				sptxtSex.innerHTML = "请输入性别！";
				sptxtSex.style.color = "red";
				//msg += "请输入性别！\n"
				document.getElementById("selectSext").focus();
				//修改标志变量
				return false;
			}else{
				sptxtSex.innerHTML="";
				//修改标志变量
				return true;
			}
			
		}
		
		<!--验证年龄-->	
		function checkAge(){
			//获取用户名输入控件对象的内容
			var txtAge = document.getElementById("txtUserAge").value;
			//信息提示框
			var sptxtAge = document.getElementById("sptxtAge");
			if(txtAge == null || txtAge == ""){
				//验证失败
				isChecked = false;
				//提示信息					
				sptxtAge.innerHTML = "请输入年龄！";
				sptxtAge.style.color = "red";
				//msg += "请输入年龄！\n"
				document.getElementById("txtUserAge").focus();
				//修改标志变量
				return false;
			}else{
				sptxtAge.innerHTML="";
				//修改标志变量
				return true;
			}
			
		}
		
		<!--验证联系方式-->	
		function checkTel(){
			//获取用户名输入控件对象的内容
			var txtTel = document.getElementById("txtUserTel").value;
			//信息提示框
			var sptxtTel = document.getElementById("sptxtTel");
			if(txtTel == null || txtTel == ""){
				//验证失败
				isChecked = false;
				//提示信息					
				sptxtTel.innerHTML = "请输入联系方式！";
				sptxtTel.style.color = "red";
				//msg += "请输入年龄！\n"
				document.getElementById("txtUserTel").focus();
				//修改标志变量
				return false;
			}else{
				sptxtTel.innerHTML="";
				//修改标志变量
				return true;
			}
			
		}
		
		<!--验证地址-->	
		function checkAddress(){
			//获取用户名输入控件对象的内容
			var txtAddress= document.getElementById("txtUserAddress").value;
			//信息提示框
			var sptxtAddress = document.getElementById("sptxtAddress");
			if(txtAddress == null || txtAddress == ""){
				//验证失败
				isChecked = false;
				//提示信息					
				sptxtAddress.innerHTML = "请输入地址！";
				sptxtAddress.style.color = "red";
				//msg += "请输入地址！\n"
				document.getElementById("txtUserAddress").focus();
				//修改标志变量
				return false;
			}else{
				sptxtAddress.innerHTML="";
				//修改标志变量
				return true;
			}
			
		}
		

				
				
				
		
		
		function checkMe(){
			//用户名验证
			var ischName = checkName();
			//密码验证
			var ischPsw = checkPsw();
			//性别
			var isSex = checkSex();
			//年龄
			var isAge = checkAge();
			//联系方式
			var isTel= checkTel();
			//地址
			var isAddress = checkAddress();
			

			
			if(ischName && ischPsw && isSex &&isAge &&isTel&&isAddress){
				//验证通过
				return true;
			}else{				
				return false;
			}
		}
		</script>



</head>
<body>

	<form action="<%=basePath%>AddStudent" method="post">

		<div class="container-fluid">
			<div class="row rowHeigth">
			<!-- 隐藏控件 -->
			<input type="hidden"  id="txtUserId"	name="txtUserId" value="${requestScope.usersB.userid }">
			
			
				<div class="form-group">
					<label class="col-sm-2 control-label">用户名</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" id="txtUserName"
							name="txtUserName" placeholder="用户名" value="${requestScope.usersB.username }" onblur="checkName();">
							<div><span id="sptxtName"></span></div>
					</div>

					<label class="col-sm-2 control-label">性别</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" id="selectSext"
							name="selectSext" placeholder="性别"  value="${requestScope.usersB.usersex }"onblur="checkSex()">
							 <div><span id="sptxtSex"></span></div>
					</div>
				</div>

			</div>


			<div class="row rowHeigth">
				<div class="form-group">
					<label class="col-sm-2 control-label">密码</label>
					<div class="col-sm-4">
						<input type="password" class="form-control" id="txtUserPsw"
							name="txtUserPsw" placeholder="Password" value="${requestScope.usersB.userpsw }" onblur="checkPsw(this);">
							<div><span id="sptxtPsw"></span></div>
					</div>

					<label class="col-sm-2 control-label">确认密码</label>
					<div class="col-sm-4">
						<input type="password" class="form-control" id="txtUserPsw2"
							name="txtUserPsw2" placeholder="Password" value="${requestScope.usersB.userpsw }">
					</div>
				</div>

			</div>

			<div class="row rowHeigth">

				<div class="form-group">
					<label class="col-sm-2 control-label" for="txtUserAge">年龄</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" id="txtUserAge"
							name="txtUserAge" placeholder="年龄" value="${requestScope.usersB.userage}" onblur="checkAge()">
							<div><span id="sptxtAge"></span></div>
					</div>

					<label class="col-sm-2 control-label" for="txtUserTel">联系方式</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" id="txtUserTel"
							name="txtUserTel" placeholder="联系方式" value="${requestScope.usersB.userpsw }" onblur="checkTel()">
							<div><span id="sptxtTel"></span></div>
					</div>
				</div>

			</div>

			<div class="row rowHeigth">
				<div class="form-group">
					<label class="col-sm-2 control-label" for="txtUserAddress">地址</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" id="txtUserAddress"
							name="txtUserAddress" placeholder="地址" value="${requestScope.usersB.useraddress }" onblur="checkAddress()">
							<div><span id="sptxtAddress"></span></div>
					</div>

					
				</div>

			</div>

			<div class="row rowHeigth">
				<div class="form-group">
					<div class="col-sm-offset-4 col-sm-2">
						<button type="submit" class="btn btn-default" onclick="return checkMe();" >保存</button>
					</div>
					<div class="col-sm-offset-2 col-sm-4">
						<button type="reset" class="btn btn-default">重置</button>
					</div>
				</div>

			</div>

		</div>

	</form>


	<script src="<%=basePath %>bootstrap/js/jquery.min.js"></script>
	<script src="<%=basePath %>bootstrap/js/bootstrap.min.js"></script>
	<script src="<%=basePath %>bootstrap/js/scripts.js"></script>
</body>
</html>